{include file='Public/header' /}
<div class="layui-layout layui-layout-admin">
{include file='Public/head' /}	
{include file='Public/side' /}	
	<div class="layui-body">
{include file='Public/crumbs' /}
		<!-- 内容主体区域 -->
		<div class="shu-body">
			<div class="layui-fluid">
				<div class="layui-row layui-col-space15">
					<div class="layui-col-md3 layui-col-xs12">
						<div class="layui-collapse">
							<div class="layui-colla-item">
								<h2 class="layui-colla-title">站点信息</h2>
								<div class="layui-colla-content layui-show">
								
									<p>PHP版本：<?php echo PHP_VERSION ?>，MySQL版本：{$mysql}</p>
                                	<p>服务器：<?php echo php_uname('s');?></p>
                                    <p>PHP运行方式：<?php echo php_sapi_name();?></p>
                                    <p>服务器IP：<?php echo GetHostByName($_SERVER['SERVER_NAME']);?></p>
									<p>Thinkphp版本：{$Think.Version}</p>
									<p>Layui版本：{$Think.CONFIG.Layui_Version}</p>
                                    <p>程序版本：{$Think.CONFIG.Version}&nbsp;<a href="javascript:;" id="update">检查更新</a>&nbsp;&nbsp;<span id="upmsg"></span></p>
								
								</div>
							</div>
						</div>
					</div>
					<div class="layui-col-md5 layui-col-xs12">
						<div class="layui-collapse">
							<div class="layui-colla-item">
								<h2 class="layui-colla-title">官方消息</h2>
								<div class="layui-colla-content layui-show">
								
									<div id="officialnews" class="panel-body">
                                    	<ul>
                                        </ul>
                                    </div>
								
								</div>
							</div>
						</div>
					</div>
					<div class="layui-col-md4 layui-col-xs12">
						<div class="layui-collapse">
							<div class="layui-colla-item">
								<h2 class="layui-colla-title">提交反馈</h2>
								<div class="layui-colla-content layui-show">
								
									<form class="layui-form" action="" method="post">
										<div class="layui-form-item">
										<textarea name="content" placeholder="请输入您反馈内容,您的支持是我们前进的最大动力！" class="layui-textarea" required  lay-verify="required"></textarea>	
										</div>				
										<div class="layui-form-item">
											<button class="layui-btn" lay-submit lay-filter="formDemo">立即提交</button>
											<button type="reset" class="layui-btn layui-btn-primary">重置</button>
									  	</div>
									</form>
									
								</div>
							</div>
						</div>
					</div>
				</div>
				<div class="layui-row layui-col-space15">
					<div class="layui-col-md12 layui-col-xs12">
						<table lay-even class="layui-table">
						  <colgroup>
							<col width="80">
						  </colgroup>
						  <thead>
							<tr>
							  <th><b>#</b></th>
							  <th><b>用户</b></th>
							  <th><b>时间</b></th>
							  <th><b>IP</b></th>
							  <th><b>日志内容</b></th>
							</tr> 
						  </thead>
						  <tbody id="list-content"></tbody>
						   
							<script id="listtemplate" type="text/html">
								{{# for(var i=0;i<d.length;i++){  }}
								<tr>
									<td>{{d[i].id}}</td>
									<td>{{d[i].name}}</td>
									<td>{{d[i].t}}</td>
									<td>{{d[i].ip}}</td>
									<td>{{d[i].log}}</td>
								</tr>
								{{# } }}
							</script>
 
						  
						</table>
						<div id="AjaxPage"></div>
						<span id="allpage"></span>
						<div class="spiner-example">加载中</div>	
						
						
						
						
					</div>
				</div>
			</div>
		</div>
		<!-- 内容主体区域 END-->
	</div>

{include file='Public/footer' /}	
<script>
//注意：折叠面板 依赖 element 模块，否则无法进行功能性操作
layui.use(['element','form','layer','jquery','laypage','laytpl'], function(){
	var $ = layui.$,element = layui.element,form = layui.form,layer = layui.layer,laypage = layui.laypage,laytpl = layui.laytpl;
	
    /**
     * [Ajaxpage laypage分页]
     * @param {[type]} curr [当前页]
     */
    Ajaxpage();

    function Ajaxpage(curr){
        var key=$('#key').val();
        $.getJSON("{:url('index/indexjson')}", {
            page: curr || 1,key:key
        }, function(data){      //data是后台返回过来的JSON数据
            $(".spiner-example").css('display','none'); //数据加载完关闭动画
            if(data==''){
                $("#list-content").html('<td colspan="20" style="padding-top:10px;padding-bottom:10px;font-size:16px;text-align:center">暂无数据</td>');
            }else{
                var nums = {$num}; //每页出现的数量
                var pagesz = {$count};  //总条数
                var pages = Math.ceil({$count}/nums);


				
				var getTpl = listtemplate.innerHTML
				,view = document.getElementById('list-content');
				laytpl(getTpl).render(data, function(html){
  				view.innerHTML = html;
				});


                laypage.render({
                    elem: $('#AjaxPage'),//容器。值支持id名、原生dom对象，jquery对象,
                    pages: pages,//总页数
                    count:pagesz,
					limit:nums,
                    skip: true,//是否开启跳页
                    skin: '#1AB5B7',//分页组件颜色
                    curr: curr || 1,
                    groups: 3,//连续显示分页数
                    jump: function(obj, first){
                        if(!first){
                            Ajaxpage(obj.curr)
                        }
                        $('#allpage').html('有'+ obj.count +'条数据，第'+ obj.curr +'页，共'+ obj.pages +'页');
                    }
                });
            }
        });
    }
	
	////////////////////////
    $(function () {
        $("#officialnews ul").html('<div class="ace-icon fa fa-spinner fa-spin orange"></div>');
        $.ajax({
            type: 'GET',
            url: '{$Think.CONFIG.NEWS_URL}?callback=?',
            success: function (data) {
                $("#officialnews ul").html("");
                $.each(data.news, function (i, news) {
                    $("#officialnews ul").append("<li>" + news.pre + "<a href=\"" + news.url + "\" title=\"" + news.title + "\" target=\"_blank\">" + news.title + "</a>&nbsp;&nbsp;&nbsp;&nbsp;" + news.time + "</li>");
                });
            },
            error: function () {
                $("#officialnews ul").html("服务器不可用，请稍后再试！");
            },
            dataType: 'json'
        });

        $("#update").click(function () {

            $("#upmsg").html("");
            $("#upmsg").addClass("ace-icon fa fa-refresh fa-spin blue");
            $.ajax({
                type: 'GET',
                url: '{$Think.CONFIG.UPDATE_URL}?v={$Think.CONFIG.Version}&callback=?',
                success: function (json) {
                    if (json.result == 'no') {
                        $("#upmsg").html("目前还没有适合您当前版本的更新！").removeClass();
                    } else if (json.result == 'yes') {
                        $("#upmsg").html("检查到新版本 " + json.ver + "，请前往“系统设置”->“<a  href=\"{:url('Update/update')}\">在线升级</a>”").removeClass();
                    }
                },
                error: function () {
                    $("#upmsg").html("悲剧了，网络故障，请稍后再试！").removeClass();
                },
                dataType: 'json'
            });

        });
    })

	/////////
	form.on('submit(formDemo)', function(data){
		loading = layer.load(2, {
			shade: [0.2,'#000']
		});
		var param = data.field;
		$.post("{:url('facebook/add',array('act'=>'update'))}",param,function(data){
		//console.log(data);
		if(data.code == 200){
			layer.close(loading);
			layer.msg(data.msg, {icon: 1, time: 1000}, function(){
				location.reload();
				//location.href="{:url('login/index')}";
			});
		}else{
			layer.close(loading);
			layer.msg(data.msg, {icon: 2, anim: 6, time: 1000});
		}
	});
	return false;
	});
  //…
});
</script>